/*********************
 *      S  start     *
 *      E  end       *
 *********************/

import Vue from 'vue';
import Router from 'vue-router';

import Index from '../views/Index.vue';
const About = () =>
    import ("@/views/About.vue")
const is_404 = () =>
    import ("@/views/404.vue")
const cart = () =>
    import ("@/views/cart/")
const sort = () =>
    import ("@/views/sort/")
const Binding = () =>
    import ("@/views/mine/Binding/")

// S  首页认证
const attest = () =>
    import ("@/views/attest")
    // E  首页认证

//  S store  商家
import store from '@/views/store/';
const storeEntering = () =>
    import ("@/views/store/entering")
const storeEnteringFail = () =>
    import ("@/views/store/enteringFail")
const storeEnteringReview = () =>
    import ("@/views/store/enteringReview")
const storeDetails = () =>
    import ("@/views/store/details")
const storeMine = () =>
    import ("@/views/store/mine/")
const storeMineData = () =>
    import ("@/views/store/mine/data")
const storeMineOrder = () =>
    import ("@/views/store/mine/order")
const storeMineorderDetails = () =>
    import ("@/views/store/mine/orderDetails")
const storeMineGoods = () =>
    import ("@/views/store/mine/goods")
const storeMineAddGoods = () =>
    import ("@/views/store/mine/addgoods")
const storeMineMerchant = () =>
    import ("@/views/store/mine/merchant")
const storeMineCard = () =>
    import ("@/views/store/mine/card")
const storeMineAddCard = () =>
    import ("@/views/store/mine/addCard.vue")
const storeMineAd = () =>
    import ("@/views/store/mine/ad")
const storeMineMember = () =>
    import ("@/views/store/mine/member")
const storeMineMemberList = () =>
    import ("@/views/store/mine/memberlist")
const storeMineAllGoods = () =>
    import ("@/views/store/mine/allGoods")
const storeMinePackage = () =>
    import ("@/views/store/mine/package")
const storeMinePackageDetails = () =>
    import ("@/views/store/mine/packagedetails")

//  S selfStore 商家自营
const selfStore = () =>
    import ("@/views/selfStore")

//  E selfStore 商家自营

// S store 商家设置
const storeSetting = () =>
    import ("@/views/store/mine/setting")

//  E store  商家

// S product 商品详情页

import product from '@/views/product/';
import productMerchant from '@/views/product/Merchant';

const productStore = () =>
    import ("@/views/product/store")
const productIntegral = () =>
    import ("@/views/product/integral")


//  E product  商品详情页

//  S mine 我的

const mine = () =>
    import ("@/views/mine/")
const mineEditInfo = () =>
    import ("@/views/mine/editInfo")
const mineAttention = () =>
    import ("@/views/mine/attention")
const mineCollect = () =>
    import ("@/views/mine/collect")
const download = () =>
    import ("@/views/mine/download")
const minemember = () =>
    import ("@/views/mine/member")
const mineIncome = () =>
    import ("@/views/mine/income")
const mineTeam = () =>
    import ("@/views/mine/team")
const mineDistribution = () =>
    import ("@/views/mine/distribution")
const minefunds = () =>
    import ("@/views/mine/funds")
const mineFirm = () =>
    import ("@/views/mine/firm")

//  E mine 我的

// S seckill  秒抢

import seckill from '@/views/seckill/';
const seckillList = () =>
    import ("@/views/seckill/List/")
const seckillMine = () =>
    import ("@/views/seckill/mine/")
const seckillProductSeckill = () =>
    import ("@/views/product/seckill")

// E seckill  秒抢

//  S integral  积分   
import integral from '@/views/integral/';
const integralRule = () =>
    import ("@/views/integral/rule")
const integralExchange = () =>
    import ("@/views/integral/exchange")
    //  E integral  积分

//  S drawApply  我的钱包 充值 提现
const drawApply = () =>
    import ("@/views/drawApply/")
const drawApplyMoney = () =>
    import ("@/views/drawApply/money")
const drawApplyType = () =>
    import ("@/views/drawApply/type")
const drawApplyRecharge = () =>
    import ("@/views/drawApply/recharge")
const drawApplyPrice = () =>
    import ("@/views/drawApply/price")
const drawApplyBonus = () =>
    import ("@/views/drawApply/bonus")
const drawApplyAdded = () =>
    import ("@/views/drawApply/added")
const drawApplyShare = () =>
    import ("@/views/drawApply/share")
const withdraw = () =>
    import ("@/views/withdraw") // 2019/9/8 提现
const withdrawIncome = () =>
    import ("@/views/withdraw/income") // 2019/9/8 提现

//  E drawApply 我的钱包 充值 提现 

//  S order  订单
const order = () =>
    import ("@/views/order/")
const orderSubmit = () =>
    import ("@/views/order/submit")
const orderdetail = () =>
    import ("@/views/order/detail/")

//  E order  订单  

//  S refund  退款   
const refund = () =>
    import ("@/views/refund/")
    //  E refund  退款  
    //  S coupon  优惠券   
const coupon = () =>
    import ("@/views/coupon/")
    //  E coupon  优惠券  

//  S submit  提交
const submit = () =>
    import ("@/views/submit/")
    //  E submit  提交



//  S address  地址
const addressAddressList = () =>
    import ("@/views/address/addressList")
const addressEditAddress = () =>
    import ("@/views/address/editAddress")
const addressList = () =>
    import ("@/views/address/list")


//  E address  地址

import video from '@/views/video';
import videoClassifyArticle from '@/views/video/classify/article';
import videoClassifyVideo from '@/views/video/classify/video';
import videoProductVideo from '@/views/video/product/video';
import videoProductArticle from '@/views/video/product/article';

//  S search  搜索
import search from '@/views/search';
//  E search  搜索


Vue.use(Router)

export default new Router({
    routes: [{
            path: '/',
            name: 'index',
            meta: {
                keepAlive: true, //页面缓存
            },
            component: Index
        },
        {
            path: '/index',
            meta: {
                keepAlive: true, //页面缓存
            },
            component: Index
        },
        {
            path: '/attest',
            component: attest
        },
        {
            path: '/about',
            name: 'about',
            component: About
        },
        {
            path: '/cart',
            name: 'cart',
            component: cart
        },
        {
            path: '/sort',
            name: 'sort',
            component: sort
        },
        {
            path: '/Seckill',
            name: 'Seckill',
            component: seckill,
        },
        {
            path: '/Seckill/mine',
            name: 'SeckillMine',
            component: seckillMine,
        },
        {
            path: '/seckill/List',
            name: 'seckill/list',
            component: seckillList,
        },
        {
            path: '/discount',
            name: 'discount',
            component: resolve => require(['@/views/discount'], resolve)
        },
        {
            path: '/product',
            name: 'product',
            component: product
        },
        {
            path: '/product/merchant',
            name: 'productMerchant',
            component: productMerchant
        },
        {
            path: '/product/store',
            name: 'productStore',
            component: productStore
        },
        {
            path: '/product/seckill',
            name: 'seckillProductSeckill',
            component: seckillProductSeckill
        },
        {
            path: '/product/integral',
            name: 'productIntegral',
            component: productIntegral
        },
        {
            path: '/store',
            name: 'store',
            component: store,
        },
        {
            path: '/store/index',
            component: store,
        },
        {
            path: '/store/list',
            name: 'storeList',
            component: resolve => require(['@/views/store/list'], resolve),
        },
        {
            path: '/store/entering',
            name: 'storeEntering',
            component: storeEntering,
        },
        {
            path: '/store/enteringReview',
            name: 'storeEnteringReview',
            component: storeEnteringReview,
        },
        {
            path: '/store/enteringFail',
            name: 'entering',
            component: storeEnteringFail,
        },
        {
            path: '/store/details',
            name: 'details',
            component: storeDetails,
        },
        {
            path: '/store/mine/',
            name: 'storeMine',
            meta: {
                keepAlive: true, //页面缓存
            },
            component: storeMine,
        },
        {
            path: '/store/mine/data',
            name: 'storeData',
            component: storeMineData,
        },
        {
            path: '/store/mine/order',
            name: 'storeOrder',
            component: storeMineOrder,
        },
        {
            path: '/store/mine/orderDetails',
            name: 'storeMineorderDetails',
            component: storeMineorderDetails,
        },
        {
            path: '/store/mine/goods',
            name: 'storeGoods',
            component: storeMineGoods,
        },
        {
            path: '/store/mine/setting',
            name: 'storeSetting',
            component: storeSetting,
        },
        {
            path: '/store/mine/allGoods',
            name: 'storeMineAllGoods',
            component: storeMineAllGoods,
        },
        {
            path: '/store/mine/package/:store_id',
            name: 'storeMinePackage',
            props: true,
            component: storeMinePackage,
        },
        {
            path: '/store/mine/package-details/:store_id',
            props:true,
            name: 'storeMinePackageDetails',
            component: storeMinePackageDetails,
        },
        {
            path: '/store/mine/addGoods',
            name: 'storeMineAddGoods',
            component: storeMineAddGoods,
        },
        {
            path: '/store/mine/merchant',
            name: 'storeMineMerchant',
            component: storeMineMerchant,
        },
        {
            path: '/store/mine/card',
            name: 'storeMineCard',
            component: storeMineCard,
        },
        {
            path: '/store/mine/addCard',
            name: 'storeMineAddCard',
            component: storeMineAddCard,
        },
        {
            path: '/store/mine/ad',
            name: 'storeMineAd',
            component: storeMineAd,
        },
        {
            path: '/store/mine/member/:store_id',
            props:true,
            name: 'storeMineMember',
            component: storeMineMember,
        },
        {
            path: '/store/mine/memberlist/:store_id',
            props:true,
            name: 'storeMineMemberList',
            component: storeMineMemberList,
        },
        {
            path: '/selfStore',
            name: 'selfStore',
            component: selfStore,
        },
        {
            path: '/mine',
            name: 'mine',
            component: mine
        },
        {
            path: '/mine/funds/:id',
            props: true,
            name: 'minefunds',
            component: minefunds
        },
        {
            path: '/mine/firm',
            component: mineFirm
        },
        {
            path: '/mine/attention',
            name: 'mineAttention',
            component: mineAttention
        },
        {
            path: '/mine/attention',
            name: 'mineAttention',
            component: mineAttention
        },
        {
            path: '/mine/editInfo',
            name: 'mineEditInfo',
            component: mineEditInfo
        },
        {
            path: '/mine/collect',
            name: 'mineCollect',
            component: mineCollect
        },
        {
            path: '/mine/download',
            name: 'download',
            component: download
        },
        {
            path: '/mine/member',
            name: 'mine/member',
            component: minemember
        },
        {
            path: '/mine/income',
            name: 'mine/income',
            component: mineIncome
        },
        {
            path: '/mine/team',
            name: 'mine/team',
            component: mineTeam
        },
        {
            path: '/mine/distribution',
            name: 'mine/distribution',
            component: mineDistribution
        },
        {
            path: '/Binding',
            name: 'Binding',
            component: Binding
        },
        {
            path: '/integral',
            name: 'integral',
            component: integral
        },
        {
            path: '/integral/rule',
            name: 'rule',
            component: integralRule
        },
        {
            path: '/integral/exchange',
            name: 'exchange',
            component: integralExchange
        },
        {
            path: '/drawApply',
            name: 'drawApply',
            component: drawApply
        },
        {
            path: '/drawApply/money',
            name: 'drawApply/money',
            component: drawApplyMoney
        },
        {
            path: '/drawApply/type',
            name: 'drawApply/type',
            component: drawApplyType
        },
        {
            path: '/drawApply/recharge',
            name: 'drawApply/recharge',
            component: drawApplyRecharge
        },
        {
            path: '/drawApply/price',
            name: 'drawApply/price',
            component: drawApplyPrice
        },
        {
            path: '/drawApply/bonus',
            name: 'drawApply/bonus',
            component: drawApplyBonus
        },
        {
            path: '/drawApply/added',
            name: 'drawApply/added',
            component: drawApplyAdded
        },
        {
            path: '/drawApply/share',
            name: 'drawApplyshare',
            component: drawApplyShare
        },
        {
            path: '/order/',
            name: 'order',
            component: order
        },
        {
            path: '/order/detail',
            name: 'order/detail',
            component: orderdetail
        },
        {
            path: '/order/submit',
            name: 'orderSubmit',
            component: orderSubmit
        },
        {
            path: '/refund/',
            name: 'refund',
            component: refund
        },
        {
            path: '/coupon/',
            name: 'coupon',
            component: coupon
        },
        {
            path: '/submit/',
            name: 'submit',
            component: submit
        },
        {
            path: '/address/addressList',
            name: 'addressAddressList',
            component: addressAddressList
        },
        {
            path: '/address/editAddress',
            name: 'addressEditAddress',
            component: addressEditAddress
        },
        {
            path: '/address/list',
            name: 'addressList',
            component: addressList
        },
        {
            path: '/video',
            name: 'video',
            component: video
        },
        {
            path: '/video/classify/article',
            name: 'videoclassifyarticle',
            component: videoClassifyArticle
        },
        {
            path: '/video/classify/video',
            name: 'videoclassifyvideo',
            component: videoClassifyVideo
        },
        {
            path: '/video/product/video',
            name: 'videoproductvideo',
            component: videoProductVideo
        },
        {
            path: '/video/product/article',
            name: 'videoproductarticle',
            component: videoProductArticle
        },
        {
            path: '/withdraw',
            name: 'withdraw',
            component: withdraw
        },
        {
            path: '/withdraw/income',
            name: 'withdrawIncome',
            component: withdrawIncome
        },
        {
            path: '/search',
            name: 'search',
            meta: {
                keepAlive: false, //页面缓存
            },
            component: search,
        },
        {
            path: '*',
            component: is_404
        },
    ],
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            if (from.meta.keepAlive) {
                from.meta.savedPosition = document.body.scrollTop;
            }
            return { x: 0, y: to.meta.savedPosition || 0 }
        }
    }
})